var id;

$(function() {
  id = ly.getUrlParam("id");

  $(".form").getFormTwo({
    id: id
  }, function(data) {
    // 基本信息
    $("#sex").val(data.medicalUserInfo.sex == 0 ? '男' : '女');
    var questionsArr = data.basicQuestionInfo;
    if (questionsArr.length > 0) {
      for(var i = 0; i < questionsArr.length; i++) {
        if (questionsArr[i].answerType == 2) {
          $("#question-box").append('<div class="row" gutter="10"><span>' + (i + 1) + '、' + questionsArr[i].questionName +'：</span><strong>'+ questionsArr[i].answer +'</strong></div>');
        } else {
          $("#question-box").append('<div class="row" gutter="10"><span>' + (i + 1) + '、' + questionsArr[i].questionName +'：</span><strong>'+ questionsArr[i].answerName +'</strong></div>');
        }
      }
    } else {
      $("#question-box").html("<div class='nodata'>暂无数据</div>")
    }

    // 档案信息
    var archivesArr = data.answerHistoryList;
    if (archivesArr.length > 0) {
	  var serviceStatisfy = '';
      for(var i = 0; i < archivesArr.length; i++) {
		if (archivesArr[i].serviceStatisfied == '0') {
			serviceStatisfy = '非常满意'
		} else if (archivesArr[i].serviceStatisfied == '1') {
			serviceStatisfy = '满意'
		} else if (archivesArr[i].serviceStatisfied == '2') {
			serviceStatisfy = '一般'
		} else if (archivesArr[i].serviceStatisfied == '3') {
			serviceStatisfy = '不满意'
		} else if (archivesArr[i].serviceStatisfied == '4') {
			serviceStatisfy = '很不满意'
		}
        $("#archives-box .archives_dl")
        .append('<dd><div class="w14" title="'+ archivesArr[i].paperName +'">'+ archivesArr[i].paperName +'</div><div class="w14">'+ (archivesArr[i].commonResult || '无') +'</div><div class="w14" title="'+ archivesArr[i].editTime +'">'+ archivesArr[i].editTime +'</div><div class="w14">'+ serviceStatisfy +'</div><div class="w14">'+ (archivesArr[i].playScore || '无') +'</div><div class="w14" title="'+ (archivesArr[i].suggestion || '') +'">'+ (archivesArr[i].suggestion || '暂无意见') +'</div><div class="w14"><a href="'+ site.interUrl +'pages/assessManage/view.html?groupid=7&id='+ archivesArr[i].id +'">查看问卷</a></div></dd>');
      }
    } else {
      $("#archives-box").html("<div class='nodata'>暂无数据</div>")
    }
  });

});

// 下载图片
function getFilePhoto(filePath) {
  var imgUrl = site.apiUrl + '/file/batchFileupload?fileAll=' + filePath;
  $("#doctorImg .imgbox").html('<img src="'+ imgUrl +'">');
}

// 跳转到VR页面
function goVR() {
  ly.goto("vr.html?userId=" + id);
}
